<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/jsf/template.xhtml">
    	<ui:define name="content">
    	
    		<h:form id="form">

    		<p:growl id="mensagem" showDetail="true" />

    		<!-- Opção PF/PJ -->
    		<p:panel styleClass="panelSemBorda">
    			<h:panelGrid columns="4" styleClass="panelSemBorda">
		    		<p:selectOneRadio id="opcaoPFouPJ" layout="custom" value="#{cadastroPDVMB.pdv.pfPj}">
		    			<f:selectItem itemLabel="PF" itemValue="1" />
		    			<f:selectItem itemLabel="PJ" itemValue="2" />
		    		</p:selectOneRadio>

		    		<h:panelGrid columns="4">
		    			<p:radioButton id="opt1" for="opcaoPFouPJ" onchange="panelPF.show();panelPJ.close();panelComum.show();panelComumNome.show()" itemIndex="0"></p:radioButton>
		    			<h:outputLabel for="opt1" value="PF" />
		    					
		    			<p:radioButton id="opt2" for="opcaoPFouPJ" onchange="panelPJ.show();panelPF.close();panelComum.show();panelComumNome.show()" itemIndex="1"></p:radioButton>
		    			<h:outputLabel for="opt2" value="PJ" />
		    		</h:panelGrid>
	    		</h:panelGrid>
    		</p:panel>
    		<!-- /Opção PF/PJ -->

    		<!-- Comum_Nome -->
    		<p:panel id="panelComumNome" widgetVar="panelComumNome" closable="true" toggleable="true" visible="false" styleClass="panelSemBorda">

    			<h:panelGrid columns="1" cellpadding="5" >

    				<h:outputText value="Nome: " />
	    			<p:inputText value="#{cadastroPDVMB.pdv.nome}" />

    			</h:panelGrid>

    		</p:panel>
    		<!-- /Comum_Nome -->

    		<!-- PF -->
    		<p:panel id="panelPF" widgetVar="panelPF" closable="true" toggleable="true" visible="false" styleClass="panelSemBorda" >

    			<h:panelGrid columns="1" cellpadding="5" >

	    			<h:outputText value="CPF: " />
	    			<p:inputText value="#{cadastroPDVMB.pdv.cpf}" />

	    			<h:outputText value="RG: " />
	    			<p:inputText value="#{cadastroPDVMB.pdv.rg}" />

    			</h:panelGrid>

    		</p:panel>
    		<!-- /PF -->

    		<!-- PJ -->
    		<p:panel id="panelPJ" widgetVar="panelPJ" closable="true" toggleable="true" visible="false" styleClass="panelSemBorda">

    			<h:panelGrid columns="1" cellpadding="5" >

    				<h:outputText value="Razão social: " />
	    			<p:inputText value="#{cadastroPDVMB.pdv.razaoSocial}" />

	    			<h:outputText value="CNPJ: " />
	    			<p:inputText value="#{cadastroPDVMB.pdv.cnpj}" />

    			</h:panelGrid>

    		</p:panel>
    		<!-- /PJ -->

    		<!-- Comum -->
    		<p:panel id="panelComum" widgetVar="panelComum" closable="true" toggleable="true" visible="false" styleClass="panelSemBorda">

    			<h:panelGrid columns="1" cellpadding="5" >

	    			<h:outputText value="Endereço: " />
		    		<p:inputText value="#{cadastroPDVMB.pdv.endereco}" />
		    		
		    		<h:outputText value="CEP: " />
		    		<p:inputText value="#{cadastroPDVMB.pdv.cep}" />
		    		
		    		<h:outputText value="Telefone: " />
		    		<p:inputText value="#{cadastroPDVMB.pdv.telefone}" />
		    		
		    		<h:outputText value="Contato: " />
		    		<p:inputText value="#{cadastroPDVMB.pdv.contato}" />

		    		<h:outputText value="Data de início do contrato: " />
		    		<p:calendar value="#{cadastroPDVMB.pdv.dataInicioContrato}" />
		    		
		    		<h:outputText value="Data de término do contrato: " />
		    		<p:calendar value="#{cadastroPDVMB.pdv.dataTerminoContrato}" />
		    		
		    		<h:outputText value="Dia de vencimento: " />
		    		<p:inputText type="number" value="#{cadastroPDVMB.pdv.diaVencimento}" />

		    		<h:outputText value="Gold/Premium: "/>
		    		<p:selectOneRadio value="#{cadastroPDVMB.pdv.goldPremium}">
			    		<f:selectItem itemLabel="Gold" itemValue="1" />
			    		<f:selectItem itemLabel="Premium" itemValue="2" />
	    			</p:selectOneRadio>

	    		</h:panelGrid>
	    		<h:panelGrid columns="2" cellpadding="5">

	    			<h4>Condições de Remuneração: </h4>
		    		<p:commandButton icon="ui-icon-help" onclick="dialogCondRemuneracao.show()"/>

		    	</h:panelGrid>
	    		<h:panelGrid columns="2" cellpadding="5">

		    		<!-- Opção Forma de Pagamento -->
	    			<p:selectOneRadio id="formaPagamento" layout="custom" value="#{cadastroPDVMB.pdv.condRemuneracao}">
    					<f:selectItem itemLabel="Fixo" itemValue="1" />
    					<f:selectItem itemLabel="Valor Acumulativo por Anunciante" itemValue="2" />
    					<f:selectItem itemLabel="Permuta" itemValue="3" />
    				</p:selectOneRadio>
    				
    				<p:radioButton id="formaPG1" for="formaPagamento" onchange="panelFormaPagamentoFixo.show();panelFormaPagamentoValorAcumulativo.close();panelFormaPagamentoPermuta.close()" itemIndex="0" />
    				<h:outputLabel for="formaPG1" value="Fixo" />
    				
    				<p:radioButton id="formaPG2" for="formaPagamento" onchange="panelFormaPagamentoFixo.close();panelFormaPagamentoValorAcumulativo.show();panelFormaPagamentoPermuta.close()" itemIndex="1" />
    				<h:outputLabel for="formaPG2" value="Valor Acumulativo por Anunciante" />
    				
    				<p:radioButton id="formaPG3" for="formaPagamento" onchange="panelFormaPagamentoFixo.close();panelFormaPagamentoValorAcumulativo.close();panelFormaPagamentoPermuta.show()" itemIndex="2" />
    				<h:outputLabel for="formaPG3" value="Permuta" />
	    			<!-- /Opção Forma de Pagamento -->

	    			<!-- Panel Forma de Pagamento - Fixo -->
	    			<p:panel widgetVar="panelFormaPagamentoFixo" closable="true" toggleable="true" visible="false">
	    				<h:panelGrid columns="2" cellpadding="5">
	    					<h:outputLabel value="Valor: " />
	    					<p:inputText value="#{cadastroPDVMB.pdv.condRemuneracaoFixo}" >
	    						<f:convertNumber type="number" maxFractionDigits="0"/>
	    					</p:inputText>
	    				</h:panelGrid>
	    			</p:panel>
	    			<!-- /Panel Forma de Pagamento - Fixo -->
	    			
	    			<!-- Panel Forma de Pagamento - Valor Acumulativo -->
	    			<p:panel widgetVar="panelFormaPagamentoValorAcumulativo" closable="true" toggleable="true" visible="false">
	    				<h:panelGrid columns="2" cellpadding="5">
	    					<h:outputLabel value="Valor Acumulativo por Anunciante:" />
	    					<p:inputText value="#{cadastroPDVMB.pdv.condRemuneracaoValorAcumulativo}" >
	    						<f:convertNumber type="number" maxFractionDigits="0"/>
	    					</p:inputText>
	    				</h:panelGrid>
	    				<h:panelGrid columns="1" cellpadding="5">
	    					<p:commandButton value="Visualizar Projeção" update="panelProjecao" actionListener="#{cadastroPDVMB.calculaProjecao}" />
	    				</h:panelGrid>
	    				<p:panel id="panelProjecao" >
	    					<h:panelGrid columns="2" cellpadding="5" border="1">
			    				<h:outputText value="Qtd de Anunciantes" style="font-weight: bold;"/>
			    				<h:outputText value="Valor (R$)" style="font-weight: bold;"/>
			    				<h:outputText value="0-4"/>
			    				<h:outputText value="0"/>
			    				<h:outputText value="5-10"/>
			    				<h:outputText value="#{cadastroPDVMB.primeiroCaso}"/>
			    				<h:outputText value="11-15"/>
			    				<h:outputText value="#{cadastroPDVMB.segundoCaso}"/>
			    				<h:outputText value="15-20"/>
			    				<h:outputText value="#{cadastroPDVMB.terceiroCaso}"/>
			    				<h:outputText value="21-25"/>
			    				<h:outputText value="#{cadastroPDVMB.quartoCaso}"/>
			    			</h:panelGrid>
	    				</p:panel>
	    			</p:panel>
	    			<!-- /Panel Forma de Pagamento - Valor Acumulativo -->
	    			
	    			<!-- Panel Forma de Pagamento - Permuta -->
	    			<p:panel widgetVar="panelFormaPagamentoPermuta" closable="true" toggleable="true" visible="false">
	    				<h:panelGrid columns="2" cellpadding="5">
	    					<h:outputLabel value="PDVs: " />
	    					<p:dataTable var="listaPDV" value="#{cadastroPDVMB.pdv.listaPDV}" rowKey="#{listaPDV.id}" selection="#{cadastroPDVMB.pdv.selecaoPDV}">
	    						<p:column selectionMode="multiple" />
	    						
	    						<p:column headerText="Nome PDV">
	    							<h:outputText value="#{listaPDV.nome}" />
	    						</p:column>
	    					</p:dataTable>
	    				</h:panelGrid>
	    			</p:panel>
	    			<!-- /Panel Forma de Pagamento - Permuta -->
	    		
	    		</h:panelGrid>
	    		<h:panelGrid columns="2" cellpadding="5">

	    			<p:commandButton value="Cadastrar" styleClass="ui-priority-primary" actionListener="#{cadastroPDVMB.cadastraPDV}" update="mensagem" />

	    		</h:panelGrid>

    		</p:panel>
    		<!-- /Comum -->

    		<!-- Pop Up - Condições de Remuneração -->
	    	<p:dialog header="Condições de Remuneração" widgetVar="dialogCondRemuneracao" appendToBody="true" modal="true">
	    		<h:panelGrid columns="1" cellpadding="5">
	    			<h3>Fixo:</h3>
	    			<h:outputText value="Texto texto texto texto texto texto texto " />
	    			<p:separator />
	    			<h3>Valor Acumulativo por Anunciante:</h3>
	    			<h:outputText value="Texto texto texto texto texto texto texto " />
	    			<br />
	    			<h:panelGrid columns="2" cellpadding="5" border="1">
	    				<h:outputText value="Qtd de Anunciantes" style="font-weight: bold;"/>
	    				<h:outputText value="Valor (R$)" style="font-weight: bold;"/>
	    				<h:outputText value="0-4"/>
	    				<h:outputText value="0"/>
	    				<h:outputText value="5-10"/>
	    				<h:outputText value="50"/>
	    				<h:outputText value="11-15"/>
	    				<h:outputText value="100"/>
	    				<h:outputText value="15-20"/>
	    				<h:outputText value="150"/>
	    				<h:outputText value="21-25"/>
	    				<h:outputText value="200"/>
	    			</h:panelGrid>
	    			<p:separator />
	    			<h3>Permuta:</h3>
	    			<h:outputText value="Texto texto texto texto texto texto texto " />
	    			<p:separator />
	    		</h:panelGrid>
	    	</p:dialog>
	    	<!-- /Pop Up - Condições de Remuneração -->

    		</h:form>
    	</ui:define>
    </ui:composition>

</html>